<?php
include './vendor/autoload.php';
include './Download.php';
$client = new GuzzleHttp\Client();
$head = [
    'timeout' => 20,
    'headers' => [
        'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8',
        'app-id' => 'wxed7e00b021bf798b',
    ],

];
$res = $client->request('GET', 'https://cdp.qiguoread.com/cdp/home/water_fall_view?pageNum=1&feedStreamId=1', $head);
$data = json_decode($res->getBody()->getContents(), true);
foreach ($data as $item) {
    $path = './' . $item['title'];
    if (!file_exists($path)) {
        $res = mkdir(iconv("UTF-8", "GBK", $path), 0777, true);
        if ($res) {
            Download::downloadImg($item['coverImageUrl'], $path . '/img.jpg');
            Download::downloadVedio($item['videoUrl'], $path);
        }
    }


}





